Shader "Unlit/Shader1"
{
    Properties
    {
        //_MainTex ("Texture", 2D) = "white" {}
        _ColorA ("Color A",Color) = (1,1,1,1)
        _ColorB ("Color B",Color) = (1,1,1,1)
        _Scale("UV Scale",Float) = 1
        _ColorStart("Color Start",Float) = 0
        _ColorEnd("Color End",Float) = 1    
    }
    SubShader
    {
        Tags { "RenderType"="Transparent"  "Queue" = "Transparent" }
        LOD 100

        Pass
        {
            Cull Off
            Blend One One //additive
            //Blend DstColor Zero 
            
            
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag

            #include "UnityCG.cginc"

            float4 _ColorA;
            float4 _ColorB;
            float _Scale;
            float _ColorStart;
            float _ColorEnd;
            
            sampler2D _MainTex;
            float4 _MainTex_ST;
            
            struct mesh_data
            {
                float4 vertex : POSITION;
                float2 uv : TEXCOORD0;
                float3 normal : NORMAL;
            };

            struct Interolators
            {
                float4 vertex : SV_POSITION;
                float3 normal : TEXCOORD0;
                float2 uv : TEXCOORD1;
            };
            
            Interolators vert (mesh_data meshData)
            {
                Interolators o;
                o.vertex = UnityObjectToClipPos(meshData.vertex);
                o.normal = UnityObjectToWorldNormal(meshData.normal);
                o.uv = meshData.uv;
                return o;
            }

            float InverseLerp(float a,float b, float v)
            {
                return (v-a)/ (b-a);
            }

            fixed4 frag (Interolators i) : SV_Target
            {
                float xOffset = cos(i.uv.x * 6.18 * 8) * 0.01;
                float t = cos( (i.uv.y + xOffset - _Time.y * 0.1) * 6.18 * 5) * 0.5 + 0.5;
                t *= 1 - i.uv.y; 
                float topBottomRemover =  t * (abs(i.normal.y) < 0.999);
                float waves = t * topBottomRemover;
                float4 gradient = lerp(_ColorA,_ColorB,i.uv.y);
                return gradient * waves;

                //return float4(i.uv.xy,0,1);
                
                //float t = saturate(InverseLerp(_ColorStart,_ColorEnd,i.uv.x));
                //float4 outColor = lerp(_ColorA,_ColorB,t);
                //return outColor;
            }
            ENDCG
        }
    }
}
